package player.view.actions;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.KeyStroke;

import player.view.MainWindow;

public class RemoveTrackAction extends AbstractAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4943043951075819258L;

	private MainWindow owner;
	
	public RemoveTrackAction(MainWindow owner){
		this.setOwner(owner);
		putValue(NAME, "Remove song");
		putValue(SHORT_DESCRIPTION, "Brisanje trenutno selektovane pjesme iz plejliste");
		putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.CTRL_MASK));
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if(owner.getSelectedRowInPlaylist() != -1){
			owner.getPlayer().stop();
			owner.getPlayer().removeFromPlaylist(owner.getSelectedRowInPlaylist());
		}
	}
	public void setOwner(MainWindow owner) {
		this.owner = owner;
	}

	public MainWindow getOwner() {
		return owner;
	}

}
